package com.glamour.hlcity.common.condition;

import java.util.HashMap;
import java.util.Map;

/**
 * 查询条件
 * 
 * @author zhaoxing.liuzx
 * 
 */
public class QueryCondition {
	private Map<String, Object> map;
	public QueryCondition() {
		map = new HashMap<String, Object>();
	}

	public QueryCondition add(String key, Object obj) {
		map.put(key, obj);
		return this;
	}

	public Object get(String key) {
		return map.get(key);
	}

	@SuppressWarnings("unchecked")
	public <T> T get(String key, Class<T> clazz) {
		return (T) map.get(key);
	}

	public Map<String, Object> asMap() {
		return new HashMap<String, Object>(map);
	}

	/**
	 * 分页查询索引值 first
	 * @param first
	 * @return
	 */
	public QueryCondition addFirst(Integer first) {
		map.put("first", first);
		return this;
	}
	
	public QueryCondition addLimit(Integer pageIndex,Integer pageSize){
		map.put("pageIndex", pageIndex);
		map.put("pageSize", pageSize);
		return this;
	}

	/**
	 * 分页查询索引值 last
	 * @param last
	 * @return
	 */
	public QueryCondition addLast(Integer last) {
		map.put("last", last);
		return this;
	}

}
